<title>后台管理员</title>

<div class="layui-card layadmin-header">
	<div class="layui-breadcrumb" lay-filter="breadcrumb">
		<a lay-href="">主页</a>
		<a><cite>系统用户</cite></a>
		<a><cite>平台列表</cite></a>
	</div>
</div>

<div class="layui-fluid">
	<div class="layui-card">

		<div class="layui-card-body">
			<div style="padding-bottom: 10px;">
				<button class="layui-btn layuiadmin-btn-admin" data-type="add">添加</button> <span class="layui-right">修改后，清空redis库8,用户退出登陆 才生效</span>
			</div>

			<table id="LAY-user-back-manage" lay-filter="LAY-user-back-manage"></table>
			<script type="text/html" id="buttonTpl">
				{{#  if(d.status == 'normal'){ }}
				<button class="layui-btn layui-btn-xs">已审核</button>
				{{#  } else { }}
				<button class="layui-btn layui-btn-primary layui-btn-xs">未审核</button>
				{{#  } }}
			</script>
		</div>
	</div>
</div>


<script>
	layui.contr1='mall';
	layui.define(['table', 'form'], function(exports){
		var $ = layui.$
			,admin = layui.admin
			,view = layui.view
			,table = layui.table
			,form = layui.form
			,util = layui.util;

		table.render({
			elem: '#LAY-user-back-manage'
			,url: './'+layui.contr1+'/list' //id,name,url,logo
			//,editTrigger: 'dblclick' // 触发编辑的事件类型（默认 click ）。 v2.7.0 新增，之前版本固定为单击触发
			,cols: [[
				{type: 'checkbox', fixed: 'left'}
				,{field: 'id', width: 80, title: 'ID', sort: true}
				,{field: 'name', title: '平台名', sort: true, edit: 'text'}
				,{field: 'url', title: '网址', sort: true, edit: 'text'}
				,{field: 'logo', title: 'logo', sort: true, edit: 'text'}
			]]
			,text: '对不起，加载出现异常！'
			,page: true
			,limit: 30
			,height: 'full-320'
		});

		//事件
		var active = {
			add: function(){
				admin.req({
					url: './'+layui.contr1+'/add'
					,type: 'get'
					,done: function(res){
						layui.table.reload('LAY-user-back-manage'); //重载表格
					}
				});
			}
		}
		$('.layui-btn.layuiadmin-btn-admin').on('click', function(){
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});

		// 单元格点击编辑后的事件
		table.on('edit(LAY-user-back-manage)', function(obj){
			admin.req({
				url: './'+layui.contr1+'/edit'
				,type: 'post'
				,data: {
					id:obj.data.id
					,field:obj.field
					,value:obj.value
				}
				,done: function(res){
					// layui.table.reload('LAY-user-back-manage'); //重载表格
					// layer.close(index); //执行关闭
				}
			});

		});
		//点击字段排序
		table.on('sort(LAY-user-back-manage)', function(obj){
			let where=form.val("layadmin-useradmin-formlist");//搜索
			where['sort_by']=obj.field;
			where['sort_order']=obj.type;
			where[layui.setter.request.tokenName]= layui.data(layui.setter.tableName)[layui.setter.request.tokenName];
			debug1(where);
			table.reload('LAY-user-back-manage', {
				initSort: obj
				,where: where
			});
		});

	});
</script>